package com.jckl.foodathon.sqlite.services;

import java.util.List;

import com.jckl.foodathon.sqlite.dao.DaoSession;
import com.jckl.foodathon.sqlite.dao.TB_BlogDao;
import com.jckl.foodathon.sqlite.model.TB_Blog;


public class BlogRepository {
	
	private static TB_BlogDao getBlogDao(DaoSession session) {
		return session.getTB_BlogDao();
    }
	
	public static void insertOrUpdate(DaoSession session, TB_Blog blog){
		getBlogDao(session).insertOrReplace(blog);
	}
	
	public static TB_Blog getBlogForId(DaoSession session, long id){
		return getBlogDao(session).load(id);
	}
	
	public static List<TB_Blog> getAllBlogs(DaoSession session){
		return getBlogDao(session).loadAll();
	}
	
	public static void clearBlogs(DaoSession session){
		getBlogDao(session).deleteAll();
	}
	
	public static void deleteBlogWithId(DaoSession session, long id){
		getBlogDao(session).delete(getBlogForId(session, id));
	}

}
